package com.ikingtech.framework.sdk.datasource.api;

import com.ikingtech.framework.sdk.core.response.R;
import com.ikingtech.framework.sdk.datasource.model.DatasourceDTO;
import com.ikingtech.framework.sdk.datasource.model.DatasourceQueryParamDTO;
import com.ikingtech.framework.sdk.datasource.model.DatasourceTableDTO;
import com.ikingtech.framework.sdk.web.annotation.PostRequest;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * @author tie yan
 */
public interface DatasourceApi {

    @PostRequest(order = 1, value = "/add", summary = "新增", description = "新增，新增成功后返回编号。")
    R<String> add(@Parameter(name = "datasource", description = "领域模型信息")
                  @RequestBody DatasourceDTO datasource);

    @PostRequest(order = 2, value = "/delete", summary = "删除", description = "删除。")
    R<Object> delete(@Parameter(name = "id", description = "编号")
                     @RequestBody String id);

    @PostRequest(order = 3, value = "/update", summary = "更新", description = "更新。")
    R<Object> update(@Parameter(name = "datasource", description = "领域模型信息")
                     @RequestBody DatasourceDTO datasource);

    @PostRequest(order = 4, value = "/list/page", summary = "分页查询", description = "分页查询，没有查询结果时返回空列表。")
    R<List<DatasourceDTO>> page(@Parameter(name = "queryParam", description = "查询条件")
                                @RequestBody DatasourceQueryParamDTO queryParam);

    @PostRequest(order = 5, value = "/list/all", summary = "全量查询", description = "全量查询，没有查询结果时返回空列表。")
    R<List<DatasourceDTO>> all();

    @PostRequest(order = 6, value = "/detail/id", summary = "查询详情", description = "查询详情，数据不存在时仍然返回成功,数据为null。")
    R<DatasourceDTO> detail(@Parameter(name = "id", description = "编号")
                            @RequestBody String id);

    @PostRequest(order = 8, value = "/schema/list", summary = "全量查询数据库(数据源信息)", description = "查询给定数据源信息下全量的数据库(数据源信息)。")
    R<List<String>> listSchema(@Parameter(name = "datasource", description = "数据源")
                               @RequestBody DatasourceDTO datasource);

    @PostRequest(order = 9, value = "/table/list/id", summary = "查询数据库表(数据源编号和数据库名称)", description = "查询数据库表(数据源编号和数据库名称)。")
    R<List<DatasourceTableDTO>> listTableById(@Parameter(name = "id", description = "数据源编号")
                                              @RequestBody String id);
}
